<?php
# 
# 此文件为程序的所有执行文件的基础
# 必须在所有文件前最先加载此文件。
# 
# 

define ('NULL_CHAR',chr(0x00));
define ('UTF32_BIG_ENDIAN_BOM'   , chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF));
define ('UTF32_LITTLE_ENDIAN_BOM', chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00));
define ('UTF16_BIG_ENDIAN_BOM'   , chr(0xFE) . chr(0xFF));
define ('UTF16_LITTLE_ENDIAN_BOM', chr(0xFF) . chr(0xFE));
define ('UTF8_BOM'               , chr(0xEF) . chr(0xBB) . chr(0xBF));

define('CONF_SETUP_PATH',dirname(__FILE__).'/configs/setup.inc');

class Config{
	public function gwtDefineFromFile($define_file){
		# 读取setup文件
		$setup = file(CONF_SETUP_PATH);
		# 判别UTF编码
		$indicator = 0;
		if(substr($setup[0],0,3) == UTF8_BOM) // 判断UTF-8 BOM 格式；
			$indicator = 3;
		elseif(substr($setup[0],0,4) == UTF32_BIG_ENDIAN_BOM) // 判断UTF32_BIG_ENDIAN_BOM格式；
			$indicator = 4;
		elseif(substr($setup[0],0,4) == UTF32_LITTLE_ENDIAN_BOM) // 判断UTF32_LITTLE_ENDIAN_BOM 格式；
			$indicator = 4;
		elseif(substr($setup[0],0,2) == UTF16_BIG_ENDIAN_BOM) // 判断UTF16_BIG_ENDIAN_BOM 格式；
			$indicator = 2;
		elseif(substr($setup[0],0,2) == UTF16_LITTLE_ENDIAN_BOM) // 判断UTF16_LITTLE_ENDIAN_BOM 格式；
			$indicator = 2;
		# 摘除UTF编码
		$setup[0] = substr($setup[0], $indicator);
		foreach($setup as $line){
			if($line[0]!= '#'){
				if(trim($line) != ''){
					list($key,$value) = split('=',$line,2);
					$key = trim($key);
					$value = trim($value);
					# 导入define 直
					define($key,$value);
				}
			}
		}
	}
}
$config = new Config();
$config->gwtDefineFromFile(CONF_SETUP_PATH);

echo DB_TYPE;







?>